// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
es6id: 14.3.9
description: Assignment of function `name` attribute ("set" accessor)
info: |
    MethodDefinition :
        set PropertyName ( PropertySetParameterList ) { FunctionBody }

    [...]
    7. Perform SetFunctionName(closure, propKey, "set").
includes: [propertyHelper.js]
features: [Symbol]
---*/

function Test() {
    var namedSym = Symbol('test262');
    var anonSym = Symbol();
    var o, setter;

    o = {
      set id(_) {},
      set [anonSym](_) {},
      set [namedSym](_) {}
    };

    setter = Object.getOwnPropertyDescriptor(o, 'id').set;
    assert.sameValue(setter.name, 'set id');
    verifyNotEnumerable(setter, 'name');
    verifyNotWritable(setter, 'name');

    setter = Object.getOwnPropertyDescriptor(o, anonSym).set;
    assert.sameValue(setter.name, 'set ');
    verifyNotEnumerable(setter, 'name');
    verifyNotWritable(setter, 'name');

    setter = Object.getOwnPropertyDescriptor(o, namedSym).set;
    assert.sameValue(setter.name, 'set [test262]');
    verifyNotEnumerable(setter, 'name');
    verifyNotWritable(setter, 'name');
}

// preheat
const NUMBER_OF_PREHEAT = 1;
for (let i = 0; i < NUMBER_OF_PREHEAT; i++) {
    Test();
}

ArkTools.jitCompileAsync(Test);
assert.sameValue(ArkTools.waitJitCompileFinish(Test), true, '[JIT] JIT disabled.');

// test
const NUMBER_OF_TEST = 1; // or 2
for (let i = 0; i < NUMBER_OF_PREHEAT; i++) {
    Test();
}
